#!/bin/bash
# Usage:  $0 <pid> <time>
echo PID $1  time: $2
PID=$1
TIME=${2:-10s}
FRAMES=${3:-4000}
sudo dtrace -p $1 -x ustackframes=${FRAMES} -n "pid$PID::*cxa_throw*:entry / pid == $PID / {@[ustack()] = count();}   tick-$TIME { exit(0); }" -o /tmp/out-throw-$PID.raw.stacks
echo Wrote to /tmp/out-throw-$PID.raw.stacks

